<template>
  <div class="order-goods-num" :class="{'order-goods-num-check':flag}" @click="chooseItem">

    <img :src="goods.image" alt="" width="50" height="50" style="">
    <el-badge :value="goods.goodsNum" :max="100" class="badge" :type="flag ? 'danger' : 'info'">
    </el-badge>

<!--    <span>{{goods.goodsNum}}</span>-->
  </div>
</template>

<script>
export default {
  name: "OrderGoodsNum",
  props:{
    goods:{
      required: true,
      type: Object,
    },
    orderGoodsItem:{
      type: Array,
      default: function(){return [];}
    },
  },
  created() {
    this.orderGoodsItem.some(item=>{
      if(item.id === this.goods.id){
        this.flag = true
        return true;
      }
    })
  },
  data(){
    return {
      flag: false,
    }
  },
  methods:{
    chooseItem(){
      this.flag = !this.flag
      this.$emit('click',this.goods,this.flag)
    }
  }
}
</script>
<style>
.badge{
  position: absolute;
  left: 0;
  top: 5px;
  .el-badge__content.is-fixed{
    left: 0;
    top: 0;
  }
}
</style>
<style scoped lang="scss">
.order-goods-num{
  position: relative;
  display: inline-block;
  //border: 1px solid #cccccc;
  //border-radius: 5px;
  //padding: 3px 10px;
  text-align: center;
  vertical-align: top;
  color: #AAAAAA;
  height: 70px;
  width: 70px;
  margin-right: 10px;
  cursor: pointer;
  //line-height: 30px;

  img{
    width: 65px;
    height: 65px;
    text-align: center;
  }
  span{
    vertical-align: super;
  }

}
.order-goods-num-check{
  //border-color: #3894ff;
  //background-color: rgba(233, 243, 255, 1);
  //color: #3894FF;
}

</style>
